home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / sys / cbm / 4714 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.7 KB  |  73 lines

  1. Path: cosy.sbg.ac.at!not-for-mail
  2. From: gwesp@cosy.sbg.ac.at (Gerhard Wesp)
  3. Newsgroups: comp.sys.cbm,gnu.gcc.help,de.comp.gnu,comp.sys.atari.8bit
  4. Subject: Re: GNU C-compiler port to 6502
  5. Date: 28 Mar 1996 14:57:04 GMT
  6. Organization: Dept. of CS, University of Salzburg
  7. Message-ID: <4je9c0$idd@esel.cosy.sbg.ac.at>
  8. References: <gnusenet199603252155.NAA11650@netcom9.netcom.com>
  9. NNTP-Posting-Host: barracuda.cosy.sbg.ac.at
  10.  
  11. In article <gnusenet199603252155.NAA11650@netcom9.netcom.com>,
  12. Toshiyasu Morita <tm@netcom.com> wrote:
  13. :
  14. >Hmmm, which certain C code sequences?
  15. :
  16.  
  17. Here goes the complete example:
  18. Let test.c be:
  19.  
  20. char *p;
  21. foo()
  22. {
  23.   while(*p);
  24. }
  25.  
  26. Compiling it with cc65 -O2 -c test.c yields test.s:
  27.  
  28. _foo
  29. Ltest1
  30. Ltest2
  31.         ldx _p
  32.         lda _p+1
  33.         stx tmp
  34.         sta tmp+1
  35.         ldy #0
  36.         lda (tmp),y
  37.         sta tmp0
  38.  
  39.         lda #0
  40.         ldx tmp0
  41.         stx tmp0
  42.         bpl *+4
  43.         lda #$FF
  44.         sta tmp0+1
  45.  
  46.         lda tmp0
  47.         ora tmp0+1
  48.         beq *+5
  49.         jmp Ltest1
  50.  
  51.         rts
  52.  
  53. _p
  54.         RESERVE 2
  55.  
  56.  
  57. Note that this is the ORIC C-compiler found at 
  58. http://www.dcs.ed.ac.uk/~axc/FLOOR1/oric.html#compiler
  59. (this is derived from lcc) and _not_ the ATARI cc65 from umich.edu. 
  60. (Just the executable names coincide).
  61. (See also <4j6952$4pc@dodo.cosy.sbg.ac.at>. Well,
  62. the code I produced for the example is not really correct as Andre pointed
  63. out, but it can easily be corrected :-).
  64. Basically, lcc did a completely unnecessary integer promotion of *p (in
  65. my opinion unnecessary).
  66.  I don't know if gcc would make better code, but I could well imagine
  67. it.
  68.  The 6502 has simply too few native registers to get along with IMHO.
  69. How would you teach gcc to add 32 bit numbers with only an 8bit accu?
  70.  
  71. Greetings,
  72. -Gerhard
  73.